export function toRouter(menus, packageName) {
  for (let i = 0; i < menus.length; i++) {
    const menu = menus[i]
    if (!menu.component) {
      // menu.component = resolve => require([`@/views/layout/Layout`], resolve)
      menu.component = () => import('@/views/layout/Layout')
    } else {
      const path = menu.component
      console.log(packageName)
      if (packageName) {
        menu.component = () => import('@/views/' + packageName + '/' + path + '/index')
      } else {
        menu.component = () => import('@/views/' + path + '/index')
      }
    }
    menu.meta = { title: menu.name, icon: menu.icon }
    if (menu.children && menu.children.length > 0) {
      toRouter(menu.children, menu.path.replace('/', ''))
    }
  }
  // return menus
}
